<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script>
    /*
        获取用户的位置：
        window.navigator.geolocation.getCurrentPosition()
    */
        // var local = window.navigator.geolocation.getCurrentPosition(function(pos){
        //     console.dir(pos)
        // } )
        function geo_success(position) {
            console.log(position.coords.latitude, position.coords.longitude);
        }

        function geo_error() {
            alert("Sorry, no position available.");
        }

        var geo_options = {
            enableHighAccuracy: true, 
            maximumAge        : 30000, 
            timeout           : 27000
        };

        var wpid = navigator.geolocation.watchPosition(geo_success, geo_error, geo_options);
    </script>
</body>
</html>